public class Rect {
    float width = 0;
    float height, area;
    //height = 0 错误的，类的属性构造不允许有对数据的操作
    Rect(){

    }
    Rect(float width, float height){//构造方法的作用是：构造属性的宽和高
        this.width = width;
        this.height = height;
    }

    void setWidth(float width){
        if(width > 0){
            this.width = width;
        }
    }

    void setHeight(float height){
        if(height > 0){
            this.height = height;
        }
    }

    float getWidth(){
        return width;
    }

    float getHeight(){
        return height;
    }

    float getArea(){
        return width*height;
    }

}
